/*******************************************************************
 * 外语翻译平台(translate) 
 *
 * 成都一亿信息技术公司 版权所有
 * 
 * Copyright (C) 2010 Transer Information Technology Co., Ltd.
 *
 * @Version : 1.0  2011-1-10 下午01:01:34
 *
 * Split.java
 *
 *******************************************************************/
package com.transer.engine.search.test;

import java.io.IOException;
import java.io.StringReader;

import net.paoding.analysis.analyzer.PaodingAnalyzer;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;

/**
 * class defination are there
 * 
 * @author Mark
 * 
 * @version 1.0 ywengineer@gmail.com
 * 
 */
public class Split {

	public static void main(String[] args) {
		try {
			// 生成analyzer实例
			Analyzer analyzer = new PaodingAnalyzer("classpath:paoding-analysis.properties");
			// 取得Token流
			TokenStream stream = analyzer.tokenStream("", new StringReader("英文|||电子通讯english"));
			// 重置到流的开始位置
			stream.reset();
			// 添加工具类
			TermAttribute termAtt = (TermAttribute) stream.addAttribute(TermAttribute.class);

			// OffsetAttribute offAtt = (OffsetAttribute)
			// stream.addAttribute(OffsetAttribute.class);
			// 循环打印所有分词及其位置
			while (stream.incrementToken()) {
				System.out.println(termAtt.term());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
